package com.czx.service.impl;

import com.czx.entity.User;
import com.czx.even.UserEven;
import com.czx.mapper.UserMapper;
import com.czx.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    @Override
    public User getUser(Integer id) {
        User user = userMapper.getUser(id);

        UserEven userEven = new UserEven(this);
        userEven.setEmail("123456@qq.com");
        userEven.setMobile("13465987451");
        applicationEventPublisher.publishEvent(userEven);
        return user;
    }
}
